//
//  CheckSendService.m
//  Daemon
//
//  Created by kare on 14-3-28.
//  Copyright (c) 2014年 彭宝全. All rights reserved.
//

#import "CheckSendService.h"
#import "ManagerObjectData.h"
#import "ASIFormDataRequest.h"
#define BASICE_URL @"http://sim.xayoudao.com/sim/index.php?r=api/"

@interface CheckSendService()

// appleid: 发送的手机号码
// stat    : 发送状态 0,初始化，1，正在发送，2，成功，3，失败
// taskid  : 任务id
// token：用户认证标志


- (void)sendResultToServices:(NSString*)_phoneNumber senderResult:(int)_result taskId:(int)_taskId userToken:(NSString*)_userToken;

@end


@implementation CheckSendService

- (id)init
{
    self = [super init];
    
    if (self)
    {
        
    }
    
    return self;
}


// appleid: 发送的手机号码
// stat    : 发送状态 0,初始化，1，正在发送，2，成功，3，失败
// taskid  : 任务id
// token：用户认证标志

- (void)sendResultToServices:(NSString*)_phoneNumber senderResult:(int)_result taskId:(int)_taskId userToken:(NSString*)_userToken
{
	NSString *urlString = [NSString stringWithFormat:@"%@sendstat",BASICE_URL];
    
    urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    ASIFormDataRequest *requestForm = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
    
    requestForm.shouldContinueWhenAppEntersBackground = YES;
    
    [requestForm setPostValue:_phoneNumber forKey:@"appleid"];
    
    [requestForm setPostValue:[NSNumber numberWithInt:_result] forKey:@"stat"];
    
    [requestForm setPostValue:[NSNumber numberWithInt:_taskId] forKey:@"taskid"];
    
    [requestForm setPostValue:_userToken forKey:@"token"];
    
    [requestForm startSynchronous];
    
	NSLog(@"requestForm = %@\n",[requestForm responseData]);
    
    NSDictionary *dic = [ManagerObjectData getCurrentData:[requestForm responseData]];
    
    NSLog(@"这是上传发送结果了\n");
    NSLog(@"dic = %@",[dic objectForKey:@"msg"]);
    NSLog(@"这是上传发送结果了\n");
}

@end
